import 'package:flutter/material.dart';

import '../../config/public_color.dart';
import '../container/separated_column.dart';

/// FileName loading_indicator
///
/// @Author lax
/// @Date 2023/4/25
///
/// @Description

class LoadingIndicator extends StatelessWidget {
  static TextStyle? defaultTextStyle;

  final String? text;

  late final TextStyle? textStyle;

  final Color? color;
  final Color? bgColor;

  final double? width;
  final double? height;

  final Widget? separator;

  LoadingIndicator({
    super.key,
    this.text,
    TextStyle? textStyle,
    this.color,
    this.bgColor,
    this.width,
    this.height,
    this.separator,
  }) {
    this.textStyle = textStyle ?? defaultTextStyle;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: bgColor,
      width: width,
      height: height,
      alignment: Alignment.center,
      child: SeparatedColumn(
        separator: separator ?? const SizedBox(height: 16),
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          CircularProgressIndicator(color: color ?? PublicColor.primary),
          Text(
            text ?? '',
            textAlign: TextAlign.center,
            style: textStyle ??
                TextStyle(fontSize: 12, color: PublicColor.hintText),
          ),
        ],
      ),
    );
  }
}
